package be.kuleuven.thesis.framework;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

import be.kuleuven.thesis.R;

public class SongDatabase {
	public static Set<Song> songs = initialize();
	public static int count = 0;
	
	public static Set<Song> initialize() {
		Set<Song> songs = new HashSet<Song>();
		Song song;
		song = new Song("Smells Like Teen Spirit", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("In Bloom", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("Come As You Are", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("Breed", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("Lithium", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("Polly", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("Territorial Pissings", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("Drain You", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("Lounge Act", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("Stay Away", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("On A Plain", "Nirvana", "Nevermind", 1991, R.drawable.nevermind);
		songs.add(song);
		song = new Song("The Man Who Sold the World", "Nirvana", "MTV Unplugged in New York", 1993, R.drawable.mtv_unplugged);
		songs.add(song);
		song = new Song("Rape Me", "Nirvana", "In Utero", 1993, R.drawable.in_utero);
		songs.add(song);
		song = new Song("All Apologies", "Nirvana", "In Utero", 1993, R.drawable.in_utero);
		songs.add(song);
		song = new Song("About A Girl", "Nirvana", "Bleach", 1989, R.drawable.bleach);
		songs.add(song);
		song = new Song("Heroin", "The Velvet Underground", "The Velvet Underground & Nico", 1967, R.drawable.velvet_underground_nico);
		songs.add(song);
		song = new Song("I Bet You Look Good On the Dancefloor", "Arctic Monkeys", "What People Say I Am, That's What I'm Not", 2006, R.drawable.whatever_people_say);
		songs.add(song);
		song = new Song("Put Your Money Where Your Mouth Is", "Jet", "Shine On", 2006, R.drawable.jet);
		songs.add(song);
		song = new Song("Diabolic Scheme", "The Hives", "Tyranossaurus Hives", 2004, R.drawable.hives);
		songs.add(song);
		song = new Song("Sitting By the Window", "Moby Grape", "Moby Grape", 1967, R.drawable.moby_grape);
		songs.add(song);
		song = new Song("Lithium", "The Bad Plus", "For All I Care", 2008, R.drawable.bad_plus);
		songs.add(song);
		song = new Song("Here Comes Your Man", "Pixies", "Doolittle", 1989, R.drawable.doolittle);
		songs.add(song);
		song = new Song("Mildred Pierce", "Sonic Youth", "Goo", 1989, R.drawable.goo);
		songs.add(song);
		song = new Song("Grounded", "Pavement", "Wowee Zowee", 1995, R.drawable.wowee_zowee);
		songs.add(song);
		return songs;
	}
	
	public static ArrayList<Song> search(String query) {
		ArrayList<Song> match = new ArrayList<Song>();
		for(Song s: songs) {
			if(s.getArtist().toLowerCase().startsWith(query.toLowerCase()) || 
					s.getAlbum().toLowerCase().startsWith(query.toLowerCase()) || 
					s.getTitle().toLowerCase().startsWith(query.toLowerCase())) {
				match.add(s);
			}
		}
		return match;
	}
	
	public static Song getSong(String title, String artist) {
		for(Song s: songs) {
			if(s.getTitle() == title && s.getArtist() == artist)
				return s;
		}
		return null;
	}
	
	public static Set<Song> generateSongs(Set<Song> likedSongs, Set<Song> dislikedSongs, Set<Song> skippedSongs, Set<Song> listenedSongs) {
		Set<Song> result = songs;
		result.removeAll(dislikedSongs);
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return result;
	}
	
	//met filter: jaar,genre,mood,tempo,(plaats)
}
